<script setup>
  /* 从 vue 中引入 ref  */
  import {ref} from 'vue'
  let counter = ref(0);
  function show() {
    alert(counter.value);
  }
  // 函数中要操作 ref 处理过的数据，需要通过 .value 形式
  let decr  = () => {
    counter.value--
  }
  let incr = () => {
    counter.value++
  }
</script>

<template>
  <div>
    <button @click="counter--">-</button>
    <button @click="decr()">-</button>
    {{ counter }}
    <button @click="counter++">+</button>
    <button @click="incr()">+</button>
    <hr>
    <button @click="show()">显示counter值</button>
  </div>
</template>

<style scoped>
</style>